<template>
  <section class="icons">
    <swiper :options="swiperOption">
      <swiper-slide v-for="(page, index) in pages" :key="index">
      <div class="icon-box" v-for="item in page" :key="item.id">
        <img :src="item.imgUrl">
        <p>{{item.desc}}</p>
      </div>
      </swiper-slide>
    </swiper>
  </section>
</template>
<script>
export default {
  data () {
    return {
      swiperOption: {
        autoplay: false
      }
    }
  },
  props: ['iconList'],
  computed: {
    pages () {
      const pages = []
      this.iconList.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>
<style lang="stylus" scoped>
@import '~styles/mixins'
.icons >>> .swiper-container
  height: 4rem
.icons
  box-sizing: border-box
  height: 4rem
  padding: .2rem 0
  overflow: hidden
  .icon-box
    width: 25%
    float: left
    overflow: hidden
    text-align: center
    padding: .1rem 0
    img
      width: 1.2rem
    p
      line-height: .5rem
      ellipsis()
</style>
